package com.wuyan.locationdog.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.WorkOrderBeanContent
import com.arcsoft.commonbase.ext.ImageOptions
import com.arcsoft.commonbase.ext.loadImage
import com.arcsoft.commonbase.ext.visibleOrGone
import com.arcsoft.commonbase.ext.visibleOrInvisible
import com.blankj.utilcode.util.AppUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R


class FeedbackDetailAdapter(@LayoutRes layoutResId: Int, data: MutableList<WorkOrderBeanContent>?) :
    BaseQuickAdapter<WorkOrderBeanContent, BaseViewHolder>(layoutResId, data) {
    var imei: String? = null

    override fun convert(holder: BaseViewHolder, item: WorkOrderBeanContent) {
        holder.apply {
            getView<TextView>(R.id.content).text = "问题描述：" + item.content
            getView<TextView>(R.id.createTime).text = item.createTime
            getView<TextView>(R.id.imei).text = imei
            getView<View>(R.id.llImei).visibleOrGone(item.recordType == 1)
            getView<View>(R.id.llImei).visibleOrGone(!imei.isNullOrEmpty())

            if (item.recordType == 1) {
                getView<TextView>(R.id.name).text = "我"
            } else {
                getView<TextView>(R.id.name).text = AppUtils.getAppName()
            }
            val imageView = getView<ImageView>(R.id.img)
            imageView.loadImage(item.img)
            imageView.visibleOrGone(!item.img.isNullOrEmpty())
            getView<ImageView>(R.id.userAvatar).loadImage(item.userAvatar, ImageOptions().apply {
                circleCrop = true
            })
            getView<View>(R.id.line).visibleOrInvisible(adapterPosition != data.size - 1)

        }
    }
}


